package dhm.com.dhmshop.framework.module.type.fragment;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.facebook.drawee.view.SimpleDraweeView;
import com.ldf.calendar.Const;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import dhm.com.dhmshop.R;
import dhm.com.dhmshop.adapter.home.ClassFicationAdapter;
import dhm.com.dhmshop.base.Presenter.PressenterImpl;
import dhm.com.dhmshop.base.netWork.Constant;
import dhm.com.dhmshop.base.netWork.LoginContract;
import dhm.com.dhmshop.entity.GetOneCategory;
import dhm.com.dhmshop.framework.base.BaseFragment;
import dhm.com.dhmshop.framework.base.MyBaseViewHolder;
import dhm.com.dhmshop.framework.module.home.activity.ListHotGoodsActivity;
import dhm.com.dhmshop.framework.module.home.entity.HomeHotGoodsList;
import dhm.com.dhmshop.framework.module.type.entity.TypeCategoryChildEntity;
import dhm.com.dhmshop.framework.module.type.model.TypeCategoryChildModel;
import dhm.com.dhmshop.framework.module.type.view.TypeCategoryChildView;
import dhm.com.dhmshop.framework.utils.GlideUtil;
import dhm.com.dhmshop.framework.utils.StringUtil;


@SuppressLint("ValidFragment")
public class TypeCategoryChildFragment extends BaseFragment<TypeCategoryChildModel> implements LoginContract.IView {


    private int pid;

    private TypeCategoryChildEntity typeCategoryChild;
    private View view;
    /**
     * 热门分类
     */
    private RecyclerView recyclerviewTypechild;
    private ClassFicationAdapter classFicationAdapter;
    private String name;
    private PressenterImpl pressenter;


    public TypeCategoryChildFragment(int id, String name) {
        pid = id;
        this.name = name;
    }

    @Override
    protected void initView(View inflate) {
        pressenter=new PressenterImpl();
        pressenter.attachView(this);
        typeCategoryChild = new TypeCategoryChildEntity();
        classFicationAdapter = new ClassFicationAdapter(getActivity());

        recyclerviewTypechild = findViewById(R.id.recyclerview_typechild);
        recyclerviewTypechild.setAdapter(classFicationAdapter);

        Map<String,String> map=new HashMap<>();
        map.put("token", Constant.TOKEN);
        map.put("pid",pid+"");
        pressenter.sendMessage(getActivity(),Constant.GetChildCategory,map,GetOneCategory.ChildCategory.class);

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {
    }

    @Override
    protected TypeCategoryChildModel initModel() {
        return new TypeCategoryChildModel();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_classification_child;
    }


    @Override
    public void requesta(Object data) {
        if (data instanceof GetOneCategory.ChildCategory){
            GetOneCategory.ChildCategory result= (GetOneCategory.ChildCategory) data;

            if (result.getCode()==1){
                classFicationAdapter.setShopList(result.getData());
            }

        }
    }

    @Override
    public void fail(String error) {

    }
}